/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exatrez.model;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author fikri
 */
@Entity
@Table(name = "observation")
@NamedQueries({
    @NamedQuery(name = "Observation.findAll", query = "SELECT o FROM Observation o")})
public class Observation implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "observation_id")
    private Integer observationId;
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "vessel_id")
    private Vessel vessel;
    
    @Column(name = "date_of_inspection")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateOfInspection;
    
    @Column(name = "location")
    private String location;   
    
    @Column(name = "name_master")
    private String nameMaster;  
    
    @Column(name = "name_chief")
    private String nameChief; 
    
    @Column(name = "name_officer")
    private String nameOfficer; 
    
    @Column(name = "name_engineer")
    private String nameEngineer; 
    
    @Column(name = "date_submit")
    @Temporal(TemporalType.TIMESTAMP)
    private Date dateSubmit;
    
   @Embedded
   private InfoAudit infoAudit;
   
   @OneToMany (mappedBy = "observation" , fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private List<ObservationSummary> summaryList;
   
   @OneToMany (mappedBy = "observation" , fetch = FetchType.LAZY, cascade = CascadeType.ALL)
   @OrderBy("observationTaskId asc")
    private List<ObservationTask> taskList;
   
   
   @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "assignee_user_id")
    private User assignee;
   
   @Column(name = "acquired_sts")
    private String acquired; 
   
//   @ManyToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "acquired_by")
//    private User acquiredBy;
   
    
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "obs_sts")
    private StatusRemarkCode status;

    public Observation() {
    }

    public Observation(Integer observationId) {
        this.observationId = observationId;
    }
    

    public Integer getObservationId() {
        return observationId;
    }

    public void setObservationId(Integer observationId) {
        this.observationId = observationId;
    }

    public Vessel getVessel() {
        return vessel;
    }

    public void setVessel(Vessel vessel) {
        this.vessel = vessel;
    }

    public Date getDateOfInspection() {
        return dateOfInspection;
    }

    public void setDateOfInspection(Date dateOfInspection) {
        this.dateOfInspection = dateOfInspection;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }
    

    public Date getDateSubmit() {
        return dateSubmit;
    }

    public void setDateSubmit(Date dateSubmit) {
        this.dateSubmit = dateSubmit;
    }

    public InfoAudit getInfoAudit() {
        return infoAudit;
    }

    public void setInfoAudit(InfoAudit infoAudit) {
        this.infoAudit = infoAudit;
    }

    public List<ObservationSummary> getSummaryList() {
        return summaryList;
    }

    public void setSummaryList(List<ObservationSummary> summaryList) {
        this.summaryList = summaryList;
    }

    public List<ObservationTask> getTaskList() {
        return taskList;
    }

    public void setTaskList(List<ObservationTask> taskList) {
        this.taskList = taskList;
    }

    public User getAssignee() {
        return assignee;
    }

    public void setAssignee(User assignee) {
        this.assignee = assignee;
    }

    public String getAcquired() {
        return acquired;
    }

    public void setAcquired(String acquired) {
        this.acquired = acquired;
    }   

    public StatusRemarkCode getStatus() {
        return status;
    }

    public void setStatus(StatusRemarkCode status) {
        this.status = status;
    }

    public String getNameMaster() {
        return nameMaster;
    }

    public void setNameMaster(String nameMaster) {
        this.nameMaster = nameMaster;
    }

    public String getNameChief() {
        return nameChief;
    }

    public void setNameChief(String nameChief) {
        this.nameChief = nameChief;
    }

    public String getNameOfficer() {
        return nameOfficer;
    }

    public void setNameOfficer(String nameOfficer) {
        this.nameOfficer = nameOfficer;
    }

    public String getNameEngineer() {
        return nameEngineer;
    }

    public void setNameEngineer(String nameEngineer) {
        this.nameEngineer = nameEngineer;
    }

//    public User getAcquiredBy() {
//        return acquiredBy;
//    }
//
//    public void setAcquiredBy(User acquiredBy) {
//        this.acquiredBy = acquiredBy;
//    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (observationId != null ? observationId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Observation)) {
            return false;
        }
        Observation other = (Observation) object;
        if ((this.observationId == null && other.observationId != null) || (this.observationId != null && !this.observationId.equals(other.observationId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "exatrez.model.Observation[ observationId=" + observationId + " ]";
    }
    
}
